from datetime import timedelta

import logging
from redis import StrictRedis


class Config(object):
    # 设置调试模式
    DEBUG = True
    SECRET_KEY = "ASDFADSFASFADSFDASF"
    # 配置数据库信息
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:mysql@127.0.0.1:3306/xjzx"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 配置redis
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 配置session信息
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)  # 设置两天有效

    # 设置日志级别
    LEVEL_NAME = logging.DEBUG


# 继承Config 实现开发者模式
class DevelopConfig(Config):
    pass


# 生产模式（线上）
class ProductConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR


# 测试模式
class TestConfig(Config):
    TESTING = True


config_dict = {
    "develop_config": DevelopConfig,
    "product_config": ProductConfig,
    "test_config": TestConfig

}
